package com.nisco.dms.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;



@Entity
@Table(name = "Ds_User_Role")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, region = "com.nisco.dms.entity")
public class UserRole extends CoreEntity {

	/**
	 * 值越小，优先级越高
	 */
	@Column(length = 2, nullable = false)
	private Integer intPriority = 99;

	@Column(length = 20)
	private String strSn;
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "roleId")
	private Role role;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "userId")
	private User user;

	/**
	 * 返回 role 的值
	 * 
	 * @return role
	 */
	public Role getRole() {
		return role;
	}

	/**
	 * 设置 role 的值
	 * 
	 * @param role
	 */
	public void setRole(Role role) {
		this.role = role;
	}

	/**
	 * 返回 user 的值
	 * 
	 * @return user
	 */
	public User getUser() {
		return user;
	}

	/**
	 * 设置 user 的值
	 * 
	 * @param user
	 */
	public void setUser(User user) {
		this.user = user;
	}

	
	
	public Integer getIntPriority()
	{
		return intPriority;
	}

	public void setIntPriority(Integer intPriority)
	{
		this.intPriority = intPriority;
	}

	public String getStrSn()
	{
		return strSn;
	}

	public void setStrSn(String strSn)
	{
		this.strSn = strSn;
	}

	/**
	 * reflectionToString将对象输出为string类型。
	 */
	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}

	
}
